home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1993 / Internet Info CD-ROM (Walnut Creek) (1993).iso / answers / comp / tcl-faq / part2 < prev    next >
Encoding:
Text File  |  1994-03-23  |  58.2 KB  |  1,735 lines

  1. Newsgroups: comp.lang.tcl,comp.answers,news.answers
  2. Path: bloom-beacon.mit.edu!hookup!news.kei.com!eff!neoucom.edu!news.ysu.edu!malgudi.oar.net!chemabs!lvirden
  3. From: lwv26@cas.org (Larry W. Virden)
  4. Subject: FAQ: comp.lang.tcl Frequently Asked Questions (2/5)
  5.     (Last updated: March 22, 1994)
  6. Message-ID: <tcl.p2_764373488@cas.org>
  7. Followup-To: comp.lang.tcl
  8. Summary: A regular posting of the comp.lang.tcl Frequently Asked Questions 
  9.     (FAQ) and their answers.  This is the second of five parts.
  10.     This part covers the how-to questions and answers.
  11. Originator: lwv26@srv01s4
  12. Keywords: tcl, expect, extended tcl, wish, tk
  13. Sender: lvirden@cas.org
  14. Supersedes: <tcl.p2_761953031@cas.org>
  15. Reply-To: lvirden@cas.org (Larry W. Virden)
  16. Organization: Chemical Abstracts Service
  17. References: <tcl.p1_764373488@cas.org>
  18. Date: Tue, 22 Mar 1994 21:58:23 GMT
  19. Approved: news-answers-request@MIT.Edu
  20. Expires: Tue, 3 May 1994 21:58:08 GMT
  21. Lines: 1711
  22. Xref: bloom-beacon.mit.edu comp.lang.tcl:10855 comp.answers:4291 news.answers:16760
  23.  
  24. Archive-name: tcl-faq/part2
  25. Version: 4.7
  26. Last-modified: March 22, 1994
  27.  
  28. Please do not be offended if I neglect to acknowledge your contribution
  29. to this FAQ!  I sometimes forget to put an attribution in.  I especially
  30. try to add them if it appears that there is further experimentation or
  31. debugging being done though.
  32.  
  33.     For more information concerning Tcl (see "tcl-faq/part1"),
  34. (see "tcl-faq/part3"), (see "tcl-faq/part4"), or (see "tcl-faq/part5").
  35.  
  36. Index of questions:
  37.  
  38. VIII. Questions on building Tcl and friends on your system:
  39.     Q8A. Is there anywhere I can find help with the details of getting 
  40.         Tcl to work on my machine?
  41.     Q8B. Why does the link step says that some of the functions Tcl,
  42.         needs are missing when I am trying to build it?
  43.     Q8C. Has anyone built Tcl 6 on an RS/6000 AIX 3.1? 
  44.     Q8D. Has anyone gotten Tcl to compile under HP-UX?
  45.     Q8E. Has anyone gotten Tcl to compile under VMS?
  46.     Q8F. What does it take to get Tcl to compile under SCO Unix?
  47.     Q8G. Why do I get format and scan errors when I run tclTest
  48.         (NeXT, AIX, etc.)?
  49.     Q8H. Why do I get lots of errors under Irix 4.0.1 when I run
  50.         tclTest?
  51.     Q8I. Does anyone else have problems with Tcl on a Cray?
  52.     Q8J. Does anyone know how to get Tk to run on a SparcBook or other
  53.         laptop with a limited number of colors?
  54.     Q8K. What does it take to get Tcl/Tk to compile on 386bsd/Linux 
  55.         or other POSIX/ANSI C systems not already supported?
  56.     Q8L. Why do I get a parse error in tkInit.c when I try to compile
  57.         Tk on my Irix machine?
  58.     Q8M. What do I need to do to install Tcl 7.x/Tk 3.x on NeXTSTEP 3.1?
  59.     Q8N. Why can't I print the draft of the Tcl/Tk book?
  60.     Q8O. Why am I getting errors on my SGI Indigo workstation?
  61.     Q8P. How do I build expect on Solaris 2.3?
  62.  
  63. IX.  How, in Tcl, can I XXX:
  64.     Q9A. get association lists or property lists?
  65.     Q9B. call one proc with the multi parameter value returned by 
  66.         another proc?
  67.     Q9C. pass an array into a proc?
  68.     Q9D. pipe output of a command back into a Tcl parsing procedure?
  69.     Q9E. merge extended Tcl into other programs such as wish or expect?
  70.     Q9F. delete a procedure from within a script?
  71.     Q9G. get parray to recognize an array variable I have created
  72.         via upvar?
  73.     Q9H. get more than 7 digits of double precision?
  74.     Q9I. grab the command line whenever a non-built-in call is made?
  75.     Q9J. get or set an environment variable?
  76.     Q9K. use numbers with leading zeroes?
  77.     Q9L. find the command line arguments to my application?
  78.     Q9M. put comments in my script, for example in a case statement?
  79.     Q9N. redirect stdin or stdout safely, including binary data?
  80.     Q9O. trap signals, and other more Unix specific functions?
  81.     Q9P. get quoted strings to work the way I want?
  82.     Q9Q. share procedures between multiple tcl applications?
  83.     Q9R. get items inserted into a list?
  84.     Q9S. perform a non-blocking read on a file identifier?
  85.     Q9T. read and write from a pipe without locking up?
  86.  
  87. X.  How, in Tk, can I XXX:
  88.     A. Question on starting Tk applications
  89.  
  90.     Q10.A.1. get my wish application to execute - I just get a wish prompt!
  91.     Q10.A.2. ,using a machine with less than 8 bit color, run?
  92.     Q10.A.3. set X11 resources for a wish application in an 
  93.         app-defaults file?
  94.     Q10.A.4. specify bitmap patterns on the command line instead of 
  95.         as a file name?
  96.     Q10.A.5. get a Motif user interface?
  97.     Q10.A.6. get an OpenLook user interface?
  98.     Q10.A.7. get Tk 3.3 to even start - I get security error messages.
  99.  
  100.     B. Questions on Tk applications and the keyboard
  101.  
  102.     Q10.B.1. change the default class bindings?
  103.     Q10.B.2. delete a binding?
  104.     Q10.B.3. change a binding while it is being executed?
  105.     Q10.B.4. bind the arrow key on my Sun keyboard?
  106.     Q10.B.5. get root's mouse bindings to work in my Tk application?
  107.  
  108.     C. Questions on Tk and X11 interactions
  109.  
  110.     Q10.C.1. get an application to also use libXt?
  111.     Q10.C.2. change the X11 cursor?
  112.     Q10.C.3. raise or lower a window?
  113.     Q10.C.4. re-map a withdrawn window id?
  114.     Q10.C.5. use Tk in a subwindow of a non-Tk X11 application?
  115.     Q10.C.6. bind <Enter> and <Leave> to a frame containing other widgets?
  116.     Q10.C.7. mix interactions between Xt and Tk/Tcl?
  117.  
  118.     D. Questions on Tk listboxes
  119.  
  120.     Q10.D.1. resize a listbox?
  121.     Q10.D.2. select two items that are not adjacent in the listbox at 
  122.         one time?
  123.     Q10.D.3. select items in more than one Tk listbox at a time?
  124.     Q10.D.4. avoid fractional white space at the end of a resizable listbox?
  125.  
  126.     E. Questions on Tk canvases
  127.  
  128.     Q10.E.1. get output from a Tk canvas?
  129.     Q10.E.2. fill a canvas which is bounded by lines as opposed to a
  130.         shape like a polygon, oval, etc.?
  131.     Q10.E.3. raise/lower canvas window objects or draw graphics onto a 
  132.         window object inside a canvas?
  133.     Q10.E.4. detect when the canvas has been resized?
  134.  
  135.     F. Other questions
  136.  
  137.     Q10.F.1. get the name of my own interpreter?
  138.     Q10.F.2. get -relief to work on my text widgets?
  139.     Q10.F.3. create a scrollable window of buttons?
  140.     Q10.F.4. pack a text widget so that it can be resized interactively?
  141.     Q10.F.5. create a widget with an upper case name?
  142.     Q10.F.6. create equal sized buttons?
  143.     Q10.F.7. vertically stack radio buttons aligning regardless of font?
  144.     Q10.F.8. initialize an entry widget with some text?
  145.  
  146. End of FAQ Index
  147.  
  148. ----------------------------------------------------------------------
  149.  
  150. ------------------------------
  151.  
  152. From: -VIII- Questions on building Tcl and friends on your system
  153. Subject: -Q8A- Is there anywhere I can find help with the details of 
  154.         getting Tcl to work on my machine?
  155.  
  156. A8A. Glad you asked!  Look in the Tcl distribution for the file called
  157. "porting.notes".  This will contain a collection of notes that various people
  158. have provided about porting Tcl to various machines and operating systems.
  159. There are also a file called "README" which should be read FIRST - before
  160. doing anything else with the code (this should always be one's first
  161. step with any package).  Finally, there is a "changes" file which details
  162. what has changed since the last release - be sure to read this to see
  163. what might need to change in your programs.
  164.  
  165. ------------------------------
  166.  
  167. From: -VIII- Questions on building Tcl and friends on your system
  168. Subject: -Q8B- Why does the link step says that some of the functions Tcl,
  169.         needs are missing when I am trying to build it?
  170.  
  171. A8B. Did you run the "config" program first, by doing a "csh ./config" or
  172. equivalent?  Without doing this, things such as strtoul or strerror
  173. are sometimes mentioned as missing.
  174.  
  175. Tcl includes equivalents for at least the following functions and include files
  176. which may not be found on some systems:
  177.  
  178. dirent.h       limits.h          stdlib.h         string.h
  179.  
  180. opendir.c      strerror.c     strstr.c         strtol.c        strtoul.c
  181.  
  182. strtod.c
  183.  
  184. ------------------------------
  185.  
  186. From: -VIII- Questions on building Tcl and friends on your system
  187. Subject: -Q8C- Has anyone built Tcl 6 on an RS/6000 AIX 3.1? 
  188.  
  189. A8C. See porting notes - especially the note about strtoul.
  190.  
  191. One user got Tcl to compile with a few minor source modifications
  192. (for example, duplicate case statements for errno and signal symbols in 
  193. tclUnixStr.c). 
  194.  
  195. A few other problems arose in the tests.  One is caused by AIX printf
  196. not formatting %#x and %#o correctly when the value to be printed is
  197. zero:  they print "0x0" and "00" instead of "0" and "0" respectively.
  198. This was reported as not a problem in earlier releases.  No fixes have
  199. been posted.
  200.  
  201. Finally, a problem occurs in open.test.  test 13.6 hangs because "cat"
  202. on the RS6000 is unbuffered.  A workaround is to change the execution
  203. of "cat" in open.test to do a "cat -u".
  204.  
  205. Dov Grobgeld <dov@menora.weizmann.ac.il> provided info on creating Tcl
  206. and Tk shared libraries under AIX 3.1.5:
  207.  
  208. For Tcl:
  209.  
  210. cc -o tkshar.o *.o -bE:tclshar.exp -bM:SRE -berok -lX11 -lm
  211. ar r libtclshr tclshar.o
  212.  
  213. For Tk:
  214.  
  215. cc -o tkshar.o *.o -bE:tkshar.exp -bM:SRE -berok -Ltcl -lX11 -lm -ltclshr
  216. ar r libtkshr tkshar.o
  217.  
  218. where tckshar.exp and tkshar.exp had lists of the external functions.
  219.  
  220. There are also problems with fonts on AIX and the IBM.  A patch is needed
  221. from IBM to fix the X server so that fonts are working
  222.  
  223. ------------------------------
  224.  
  225. From: -VIII- Questions on building Tcl and friends on your system
  226. Subject: -Q8D- Has anyone gotten Tcl to compile under HP-UX?
  227.  
  228. A8D. See the porting notes.
  229.  
  230. ------------------------------
  231.  
  232. From: -VIII- Questions on building Tcl and friends on your system
  233. Subject: -Q8E- Has anyone gotten Tcl to compile under VMS?
  234.  
  235. A8E. Information from jkimball@src.honeywell.com (John Kimball) on
  236. May 4, 1993 was that he had gotten Tcl 6.7 and Tk 3.2 ported to VMS
  237. 5.5.  See the catalog for the file information.
  238.  
  239. ------------------------------
  240.  
  241. From: -VIII- Questions on building Tcl and friends on your system
  242. Subject: -Q8F- What does it take to get Tcl to compile under SCO Unix?
  243.  
  244. A8F. Add a "#undef select" to tkEvent.c, and remove the reference to 
  245. TK_EXCEPTION around line 460 of main.c.
  246.  
  247. Tk uses its own scheme for allocating the border colors for its 3D
  248. widgets, which causes problems when running TK on a system with
  249. "PseudoColor" display class, and a 16-cell colormap.
  250.  
  251. If you can't go to eight bitplanes, you can instead start the server
  252. with a "-static" (Xsco) or "-analog" (Xsight) option, making the
  253. display class become "StaticColor".  This makes the entire colormap
  254. read-only, and it will return the color that most closely maps to the
  255. desired color as possible.
  256.  
  257. This information is from Keith Amann <Keith_Amann@stortek.com>
  258.  
  259. ------------------------------
  260.  
  261. From: -VIII- Questions on building Tcl and friends on your system
  262. Subject: -Q8G- Why do I get format and scan errors when I run tclTest
  263.         (NeXT, AIX, etc.)?
  264.  
  265. A8G. That's a problem (scanf/printf) many systems seem to have.  Don't
  266. worry too much about it - just don't use these 'advanced' features.  If
  267. you're hacking C, you'll have the same problems.
  268.  
  269. ------------------------------
  270.  
  271. From: -VIII- Questions on building Tcl and friends on your system
  272. Subject: -Q8H- Why do I get lots of errors under Irix 4.0.1 when I run
  273.         tclTest?
  274.  
  275. A8H. There's a bug in the 4.0.1 optimizer that's fixed in 4.0.2.
  276. Compile tclVar.c using -O0 (no optimization).
  277.  
  278. ------------------------------
  279.  
  280. From: -VIII- Questions on building Tcl and friends on your system
  281. Subject: -Q8I- Does anyone else have problems with Tcl on a Cray?
  282.  
  283. A8I. See the porting notes for a set of changes mentioned.  Also,
  284. Booker C. Bense <benseb@grumpy.sdsc.edu> reports that version 3.0.1.6
  285. has some real problems with char pointers, causing Tcl to crash.  Using
  286. version 3.0.2.1, things are much better, except for a minor formatting
  287. problem and serious problems with scan.
  288.  
  289. ------------------------------
  290.  
  291. From: -VIII- Questions on building Tcl and friends on your system
  292. Subject: -Q8J- Does anyone know how to get Tk to run on a SparcBook or other
  293.         laptop with a limited number of colors?
  294.  
  295. A8J. On a SparcBook, if you start openwin (the OpenWindows server starting
  296. command) as:
  297.  
  298. openwin -dev "/dev/fb staticvis"
  299.  
  300. you get a static visual color model that Tk copes with better than the
  301. default.  Some things are ugly, but not as ugly as monochrome.
  302.  
  303. ------------------------------
  304.  
  305. From: -VIII- Questions on building Tcl and friends on your system
  306. Subject: -Q8K- What does it take to get Tcl/Tk to compile on 386bsd/Linux 
  307.         or other Posix/ANSI C systems not already supported?
  308.  
  309. A8K. Patches for 386BSD were posted to comp.lang.tcl back in Nov. 1992 to
  310. alt.sources.  See one of the ftp archive sites for this group for them.
  311. Basically, there were some setting of defines and a few places where 
  312. const char * had to be used in place of char *.  
  313.  
  314. ------------------------------
  315.  
  316. From: -VIII- Questions on building Tcl and friends on your system
  317. Subject: -Q8L- Why do I get a parse error in tkInit.c when I try to compile
  318.         Tk on my Irix machine?
  319.  
  320. A8L. Jon Knight <J.P.Knight@loughborough.ac.uk> reports that the version of
  321. Irix that he is using doesn't define a uid_t.  One needs to define one 
  322. somewhere (or comment out the lines causing the problems) to get the compile
  323. to continue.
  324.  
  325. ------------------------------
  326.  
  327. From: -VIII- Questions on building Tcl and friends on your system
  328. Subject: -Q8M- What do I need to do to install Tcl 7.1/Tk 3.4 on NeXTSTEP 3.1?
  329.  
  330. A8M.  I have indicated in the past that this particular question seems
  331. to generate controversy - I have replaced previous explanations with the
  332. latest msg from someone who sounds authoritative...
  333.  
  334. From: Robert Nicholson <robert@steffi.demon.co.uk>
  335.  
  336. This is for TCL7.1 and TK3.4 
  337.  
  338. This is a variation on Thomas Funke's entry.
  339.  
  340. Installing TCL7.1 on NeXT
  341. =========================
  342.  
  343. To install tcl7.1 on NeXTSTEP 3.1 you must:
  344.  
  345. - run configure with predefined CPP:
  346.     type "sh" to run a Bourne shell.
  347.     then type
  348.     CPP='cc -E' ./configure
  349.  
  350. - edit Makefile:
  351.  
  352.   add tmpnam.o to COMPAT_OBJS:
  353.   COMPAT_OBJS =      getcwd.o waitpid.o strtod.o tmpnam.o
  354.  
  355. At this point you probably want to rename the all calls to strtod and
  356. tmpnam to something else in order to distinguish them from those that
  357. are supplied in the NeXT libraries libsys_a.a.  You can do this by 
  358. adding the following line to AC_FLAGS
  359.  
  360.     -Dstrtod=newstrtod -Dtmpnam=newtmpnam
  361.  
  362. and renaming the names of the definitions in the appropriate
  363. compat/*.c files.
  364.  
  365. To check everything is working correctly open a tclsh 
  366.  
  367. % expr {"0" == "+"} 
  368. 0
  369.  
  370. Using the wrong strtod function will cause this test to return 1 which
  371. is a serious error.  Ignore the precision errors.
  372.  
  373. Installing TK3.4 on NEXTSTEP 3.1
  374. ================================
  375.  
  376. There is a call to strtod in TK3.4 so you should link against
  377. ../tcl-7.1/compat/strtod.o and apply the -Dstrtod=newstrtod
  378. to AC_FLAGS in Tk also.
  379.  
  380. Note:Tk's raise test will fail when running the tvtwm window manager.
  381. Changing to either twm or even better fvwm ensures that this test will
  382. succeed. 
  383.  
  384.  
  385.  
  386. ------------------------------
  387.  
  388. From: -VIII- Questions on building Tcl and friends on your system
  389. Subject: -Q8N- Why can't I print the draft of the Tcl/Tk book?
  390.  
  391. A8N.  From ouster@cs.Berkeley.EDU (John Ousterhout):
  392.  
  393. Here's my form letter that seems to explain most of the problems people
  394. have had printing parts of the book:
  395.  
  396. Some old versions of the Transcript spooler software cannot properly
  397. handle encapsulated Postscript files within another Postscript file
  398. when they do page reversal.  They tend to garble the page structure of
  399. the file, causing an error at the point of the first EPS file.  Part
  400. II of the Tcl book has lots of EPS files embedded in it, one for
  401. each screen dump.  If your printer cannot print this file I suggest
  402. checking to see if page reversal is enabled for your printer.  If
  403. so, try asking your local system wizard to disable it for you;  this
  404. should allow the file to print.  Or, find some other way to dump the
  405. Postscript file directly to the printer without going through the
  406. spooling software (e.g. perhaps you can simply cat it to the printer's
  407. serial port).
  408.  
  409. Others have suggested:
  410.  
  411.  The embedded pictures have CR as the line separator instead of LF and
  412.  this may be causing the problem. Try translating them to LFs ...
  413.  
  414.    tr '\015' '\012' <book.p2.ps >fixedbook.p2.ps
  415.  
  416. and:
  417.  
  418.  This is not the original poster's problem but in countries using A4
  419.  paper and on a particular printer, the Dataproducts LZR1260E, the frame
  420.  size causes the printing to be stretched vertically. This happens with
  421.  other Framemaker generated documents by the way. A PS interpreter bug
  422.  no doubt. The fix is to edit the dimensions for A4 paper. This shell
  423.  script does both fixes.
  424.  
  425. #!/bin/sh
  426. cat $1 | tr '\015' '\012' | sed '/FMDOCUMENT$/s/612 792/595 842/'
  427.  
  428. ------------------------------
  429.  
  430. From: -VIII- Questions on building Tcl and friends on your system
  431. Subject: -Q8O- Why am I getting errors on my SGI Indigo workstation?
  432.  
  433. A8O. From Gordon Lack <gml4410@ggr.co.uk> we are told that
  434. the SGI c compiler has some bugs with variable arguments.
  435.  
  436. tclVar.c must be compiled with -O0 at IRIX C 4.0.1 because of a
  437. compiler bug with varargs.
  438.  
  439.    Done by placing specific rule into Makefile.
  440.  
  441. > # GGR SG needs -O0 for varargs at 4.0.1
  442. >
  443. > CC_SWITCHES0 =  -O0 -I. -I${SRC_DIR} ${AC_FLAGS} ${MATH_FLAGS} \
  444. > ${GENERIC_FLAGS} ${PROTO_FLAGS} ${MEM_DEBUG_FLAGS} \
  445. > -DTCL_LIBRARY=\"${TCL_LIBRARY}\"
  446. >
  447. > tclVar.o: tclVar.c
  448. >         $(CC) -c $(CC_SWITCHES0) $<
  449.  
  450.  
  451. ------------------------------
  452.  
  453. From: -IX-  How, in Tcl, can I XXX:
  454. Subject: -Q8P- How do I build expect on Solaris 2.3?
  455.  
  456. A8P. From jra@hrcms.jazz.att.com (Jeff Abramson) we are told that,
  457.  
  458. > using either SunPro cc 2.0.1 or gcc 2.5.8 with
  459. > no problems.  For SunPro I do:
  460. >  
  461. >         CC=cc ./configure --prefix=directory_of_your_choice
  462. >         make CC=cc
  463. >  
  464. > For gcc I do:
  465. >  
  466. >         CC="gcc -fwritable-strings" ./configure \
  467. >        --prefix=directory_of_your_choice
  468. >        make CC="gcc -fwritable-strings"
  469.  
  470.  
  471. ------------------------------
  472.  
  473. From: -IX-  How, in Tcl, can I XXX:
  474. Subject: -Q9A- association lists or property lists?
  475.  
  476. A9A. Use Extended Tcl arrays or keyed lists.
  477.  
  478. For example, if you did a:
  479.  
  480. keylset ttyFields ttyName tty1a
  481. keylset ttyFields baudRate 57600
  482. keylset ttyFields parity strip
  483.  
  484. And then an "echo $ttyFields", you'd get:
  485.  
  486.     {ttyName tty1a} {baudRate 57600} {parity strip}
  487.  
  488. ------------------------------
  489.  
  490. From: -IX-  How, in Tcl, can I XXX:
  491. Subject: -Q9B- call one proc with the multi parameter value returned by 
  492.         another proc?
  493.  
  494. A9B. Assuming y requires multiple args and x returns multiple words, use 
  495.     Tcl's eval command :
  496.  
  497.     eval y [x]
  498.  
  499. ------------------------------
  500.  
  501. From: -IX-  How, in Tcl, can I XXX:
  502. Subject: -Q9C- pass an array into a proc?
  503.  
  504. A9C. Use upvar rather than try to use global variables when possible.  If
  505. the function is event driven, you are forced to use global variables.
  506.  
  507.  
  508. # print elements of an array
  509. proc show_array arrayName {
  510.     upvar $arrayName myArray
  511.  
  512.     foreach element [array names myArray] {
  513.        puts stdout "${arrayName}($element) =  $myArray($element)"
  514.     }
  515. }
  516.  
  517. set arval(0) zero
  518. set arval(1) one
  519. show_array arval
  520.  
  521.  
  522. To return an array from a procedures, just take the array name in as an
  523. argument, as above.  Any changes you make in the array will be made in
  524. the parent's array as well.
  525.  
  526. Extended Tcl introduces a concept called keyed lists which are arrays
  527. made out of lists of key-value pairs and can be passed by value to routines,
  528. over networks, etc.
  529.  
  530. ------------------------------
  531.  
  532. From: -IX-  How, in Tcl, can I XXX:
  533. Subject: -Q9D- pipe output of a command back into a Tcl parsing 
  534.         procedure?
  535.  
  536. A9D. For example, to grep a pattern out of a range of files, one might
  537. do:
  538.  
  539. karl@NeoSoft.com (Karl Lehenbauer) writes:
  540.  
  541. set files [glob /home/cole/stats/*]
  542.  
  543. proc parseInfo { site } {
  544.    global files
  545.  
  546. #
  547. # site is chosen from a listbox earlier
  548. #
  549.    set in [open [concat "|/usr/bin/grep $site $files"] r]
  550.  
  551.    while {[gets $in line]>-1} {
  552.       puts stderr $line
  553.    }
  554.    catch {close $in}
  555. }
  556.  
  557. One thing:  the matching strings are _not_ returned in directory order.
  558.  
  559. But what if I want to check the return code AND use the output of 
  560. the command?  kennykb@dssv01.crd.ge.com (Kevin B. Kenny) writes:
  561.  
  562. if [catch {exec ls} data] {
  563.         # The exec got an error, and $errorCode has its termination status
  564. } else {
  565.         # The exec succeeded
  566. }
  567. # In any case, `data' contains all the output from the child process.
  568.  
  569. Note that Karl Lehenbauer adds that errorCode will be a list containing
  570. three elements, the string "CHILDSTATUS", the process ID of the child,
  571. and the exit status of the child.
  572.  
  573. ------------------------------
  574.  
  575. From: -IX-  How, in Tcl, can I XXX:
  576. Subject: -Q9E- merge extended Tcl into other programs such as wish or expect?
  577.  
  578. A9E. The latest version of extended Tcl, tclX 6.7c, has been enhanced to
  579. make it easier to incorporate into applications.
  580.  
  581. ------------------------------
  582.  
  583. From: -IX-  How, in Tcl, can I XXX:
  584. Subject: -Q9F- delete a procedure from within a script?
  585.  
  586. A9F. rename procedureName ""
  587.  
  588. ------------------------------
  589.  
  590. From: -IX-  How, in Tcl, can I XXX:
  591. Subject: -Q9G- get parray to recognize an array variable I have created
  592.         via upvar?
  593.  
  594. A9G. Right now (June, 1992) upvar doesn't allow you to attach to an
  595. individual element of an array.  This is considered a bug by 
  596. Mr. Ousterhout and has been place on a bug list.
  597.  
  598. ------------------------------
  599.  
  600. From: -IX-  How, in Tcl, can I XXX:
  601. Subject: -Q9H- get more than 7 digits of double precision ?
  602.  
  603. A9H. In Tcl 6.x, modify the tclExpr.c module to use %lf instead of %g.  In
  604. Tcl 7.x, set the global variable tcl_precision instead.
  605.  
  606. ------------------------------
  607.  
  608. From: -IX-  How, in Tcl, can I XXX:
  609. Subject: -Q9I- grab the command line whenever a non-built-in call is made?
  610.  
  611. A9I. The procedure "unknown" is called automatically with arguments 
  612. containing the command and its arguments for any command that couldn't be 
  613. found.  In fact, Tcl and Extended Tcl use this feature to provide demand
  614. loaded commands, and even entire libraries.
  615.  
  616. So by modifying the unknown procedure you can provide your own extended
  617. functionality, or even remove the demand loading capability if you so
  618. desire.
  619.  
  620. ------------------------------
  621.  
  622. From: -IX-  How, in Tcl, can I XXX:
  623. Subject: -Q9J- get or set an environment variable?
  624.  
  625. A9J. By using something like the following.
  626.  
  627. set olddisplay $env(DISPLAY)
  628. set env(DISPLAY) unix:0
  629.  
  630. Thanks to "Joel Fine" <joel@cs.berkeley.edu> for the answer.
  631.  
  632. ------------------------------
  633.  
  634. From: -IX-  How, in Tcl, can I XXX:
  635. Subject: -Q9K- use numbers with leading zeroes?
  636.  
  637. A9K. Dave Morriss was recently having problems because he was trying
  638. to do something like:
  639.  
  640. set index [expr [exec date +%W]%[llength $pop_server_list]]
  641.  
  642. but during the 9th and 9th week of the year, he got errors - 08 and 09
  643. are not valid octal numbers in Tcl.
  644.  
  645. Some of the solutions provided were:
  646.  
  647. From George A. Howlett <george.howlett@att.com>, we got:
  648.  
  649. set wknum [format "%g" [exec date +%W]]
  650. set index [expr [exec $wknum%[llength $pop_server_list]]
  651.  
  652. From Fred Feirtag <feirtag@wave.nrl.navy.mil> :
  653.  
  654. set index [expr (1[exec date +%W]-100)%[llength $pop_server_list]]
  655.  
  656. From Dan R. Schenck <schendr@Texaco.COM>:
  657.  
  658. set index [expr [string trimleft [exec date +%W] 0]%[llength $pop_server_list]]
  659.  
  660. ------------------------------
  661.  
  662. From: -IX-  How, in Tcl, can I XXX:
  663. Subject: -Q9L- find the command line arguments to my application?
  664.  
  665. A9L.  If you are using extended Tcl or Expect, you will find the parameters in
  666. the Tcl variable argv as a list.  Note that in extended Tcl, the name of 
  667. the program is in the Tcl variable programName and NOT in argv[0].  Thanks to
  668. brad@NeoSoft.com (Brad Morrison) and bachww@rtsg.mot.com (Bud Bach) for
  669. this answer.
  670.  
  671. ------------------------------
  672.  
  673. From: -IX-  How, in Tcl, can I XXX:
  674. Subject: -Q9M- put comments in my script, for example in a case statement?
  675.  
  676. A9M. You can't have comments where you have them.  Move the comments inside
  677. of the "{" for the case that you want.  Your code should read:
  678.  
  679. case 1 {
  680.   -1    {
  681.         #
  682.         # Cannot find information sought
  683.         #
  684.         exit 2
  685.         }
  686.    0    {
  687.         #
  688.         # Error in arguments
  689.         #
  690.         exit 1
  691.         }
  692.    default    {
  693.         #
  694.         # Desired information found
  695.         #
  696.         exit 0
  697.         }
  698. }
  699.  
  700. Thanks to gwlester@cpu.com (Gerald W. Lester).
  701.  
  702. ------------------------------
  703.  
  704. From: -IX-  How, in Tcl, can I XXX:
  705. Subject: -Q9N- redirect stdin or stdout safely, including binary data?
  706.  
  707. A9N. With Extended Tcl you can safely do stuff like:
  708.  
  709.         set infp [open "|compress -dc $fileName"]
  710.         set outfp [open "|gzip -c $newFileName" w]
  711.  
  712.         copyfile $infp $outfp
  713.  
  714. Thanks to karl@NeoSoft.com (Karl Lehenbauer) for the code example.
  715.  
  716. ------------------------------
  717.  
  718. From: -IX-  How, in Tcl, can I XXX:
  719. Subject: -Q9O- trap signals, and other more Unix specific functions?
  720.  
  721. A9O. Extended Tcl offers many of these types of functions.  For instance,
  722. extended Tcl has the 'signal' command:
  723.  
  724.         signal action siglist [command]
  725.  
  726.         where action is one of "default", "ignore", "error", "trap", "get",
  727.         plus the POSIX "block" and "unblock" actions (available only on
  728.         POSIX systems, of course).  Siglist is a list of either the symbolic
  729.         or numeric Unix signal (the SIG prefix is optional).  Command is your
  730.         error handler (or a simple {puts stdout "Don't press *that* key!"}  :-)
  731.  
  732. "trap" does what you expect, and I find "error" and "get" to be
  733. extremely useful in interactive programs which demand keyboard
  734. traversal.
  735.  
  736. Extended Tcl also has things like fork, etc.
  737.  
  738. Answer by brad@NeoSoft.com (Brad Morrison).
  739.  
  740. ------------------------------
  741.  
  742. From: -X-  How, in Tcl, can I XXX:
  743. Subject: -Q9P- get quoted strings to work the way I want?
  744.  
  745. A long article dealing with the issues can be found at
  746. ftp://harbor.ecn.purdue.edu/pub/tcl/docs/README.programmer
  747.  
  748. Here are some short answers:
  749.  
  750. Q. I'm trying to build up a command for later execution but am
  751. having trouble with variable values that include whitespace
  752. or special characters.
  753.  
  754. A. The safest way to build up commands is to use the list command
  755. so that you can keep track of the list structure.  Avoid using
  756. double quotes because you can end up with an extra trip through
  757. the evaluator.  We'll illustrate this with a command to create
  758. a button that prints out the label on the button when you click it.
  759.     Wrong answer #1:
  760.     button $myname -text $label -command "puts stdout $label"
  761.     Why? because if $label has whitespace then the puts command will
  762.     be passed the wrong number of arguments.  If $label has $ or [ ]
  763.     characters, they will be interpreted instead of printed.
  764.     Good answer #2:
  765.     button $myname -text $label -command [list puts stdout $label]
  766.     Why? because list will properly quote the value of $label
  767.  
  768. Q. I'm trying to build up a command for later execution but am
  769. having trouble getting some variables to evaluate now, and some
  770. to evaluate later when the command is run.
  771.  
  772. A. The cleanest way to do this is to define a procedure that hides
  773. the use of the variables at run time, and then build up a call to
  774. that procedure using the list command as described previously.  (You
  775. can even define the procedure on the fly.  It will have global scope
  776. even it if is created within another procedure.)
  777.     Wrong answer #1:
  778.     button $myname -text $label -command \
  779.         [list puts stdout $ArrayOfDynamicStuff($label)]
  780.     Why? The array value will be substituted when the button is created,
  781.     not later on when the button is clicked.  Also, note that the
  782.     command is executed at the global scope, so it is not necessary
  783.     to include a "global ArrayOfDynamicStuff" in the command.
  784.     Wrong answer #2 (backquotes and list):
  785.     button $myname -text $label -command \
  786.         [list puts stdout \$ArrayOfDynamicStuff($label)]
  787.     Why? Here the list command and the backquote of $ are fighting with
  788.     each other.  The command ends up being something like:
  789.         puts stdout {$ArrayOfDynamicStuff(foo)}
  790.     which prevents the substitution of the value of the array element.
  791.     Dubious answer #3 (backquotes and double-quotes):
  792.     button $myname -text $label -command \
  793.         "puts stdout \$ArrayOfDynamicStuff($label)"
  794.     Why? This only works if the value of $label has no special characters
  795.     or whitespace.
  796.     Clean answer #4 (proc):
  797.     proc doit { i } {
  798.         global ArrayOfDynamicStuff
  799.         puts stdout $ArrayOfDynamicStuff($i)
  800.     }
  801.     button $myname -text $label -command [list doit $label]
  802.     Why? Using little TCL procs for your button commands is a good habit
  803.     because it eliminates most needs for fancy quoting, and it
  804.     makes it easier to tweak the button command later on.
  805.  
  806. Q. I'm trying to pass along a variable number of args to another procedure
  807. but I'm having trouble getting the $args to expand right.
  808.  
  809. A. Avoid using eval and double quotes because that results in
  810. an extra trip through the interpreter.  The eval command will do
  811. a concat of its arguments if there are more than one, so that
  812. pretty much eliminates the need to group things with double quotes.
  813. Let's extend the button example:
  814.     Wrong answer #1:
  815.     proc mybutton { myname label args } {
  816.         button $myname -text $label -command [list puts stdout $label] $args
  817.     }
  818.     Why? All the extra arguments to mybutton are grouped into one list element
  819.     that is but into the value of $args.  However, the button command
  820.     expects to see individual arguments, not a sub-list.
  821.     Wrong answer #2:
  822.     proc mybutton { myname label args } {
  823.         eval "button $myname -text $label -command [list puts stdout $label] $args"
  824.     }
  825.     Why? The double quotes allow expansion of $label as well as $args, so if
  826.     $label has any whitespace, the button command will be malformed
  827.     Good answer #3:
  828.     proc mybutton { myname label args } {
  829.         set cmd {button $myname -text $label -command [list puts stdout $label]}
  830.         eval $cmd $args
  831.     }
  832.     Why? Eval will first concatenate its two arguments and then run the
  833.     result through the interpreter.  Think of this as stripping off the
  834.     outer curly braces from $cmd and $arg and making a single list
  835.     with all the elements of both.  $label will be evaluated exactly
  836.     once, so the puts command will remain good, and whatever went into
  837.     args will also be processed exactly one time.
  838.  
  839. Q. Why do I get a syntax error in an if/while/for statement?
  840. A. You may have written something like
  841.     wish: set foo bar
  842.     wish: if {$foo == bar} {puts stdout bar}
  843.     syntax error in expression "$foo == bar"
  844.  
  845. in which bar is interpreted as neither a string nor a variable, since
  846. strings as operands in expressions MUST be surrounded by double quotes
  847. or braces. 
  848.  
  849. Change to
  850.     wish: if {$foo == "bar"} {puts stdout bar}
  851. or
  852.     wish: if {$foo == {bar}} {puts stdout bar}
  853.  
  854. always in expressions, depending on if you want expansion performed or
  855. not. 
  856.  
  857. Contributed by "Jesper Blommaskog" <d9jesper@dtek.chalmers.se>
  858.  
  859. ------------------------------
  860.  
  861. From: -X-  How, in Tcl, can I XXX:
  862. Subject: -Q9Q- share procedures between multiple tcl applications?
  863.  
  864. A9Q.  Rather than sourcing the files explicitly, build a tcl library:
  865.  
  866. Step 1.  Put the files in a common directory
  867.  
  868. Step 2.  Build the tclIndex for the "library".  I use a Makefile with
  869. a convention like:
  870.  
  871. install.index:
  872.         (cd ${DESTDIR}/tclscripts/lib; \
  873.         echo 'source /usr/local/lib/tcl/init.tcl;\
  874.      auto_mkindex . *.tk' | tcl ; exit 0)
  875.  
  876. Step 3. Modify your tcl scripts to reference the library:
  877.  
  878. e.g.:
  879.  
  880. # local additions
  881. lappend auto_path /usr/local/lib/tcl_local $env(RDS_TCL_SCRIPTS)/lib
  882.  
  883. Now, as soon as your script tried to reference a procedure in the library,
  884. the "unknown" command autoloads the procedure for you.
  885.  
  886. Contributed by Joe VanAndel <vanandel@ncar.ucar.edu>
  887.  
  888.  
  889. ------------------------------
  890.  
  891. From: -X-  How, in Tk, can I XXX:
  892. Subject: -Q9R- get items inserted into a list?
  893.  
  894. A9R.  A user asked why
  895.  
  896.     linsert $list 0 ..
  897.  
  898. did not result in .. being inserted into list.
  899.  
  900. d9jesper@dtek.chalmers.se (Jesper Blommaskog) replied:
  901.  
  902. When doing list operations other than lappend, you must save the
  903. returned value. This applies to list, lindex, lrange, lreplace at
  904. least.
  905.  
  906. In this example, you would perhaps want to do something like:
  907.  
  908.     set list [ linsert $list 0 .. ] 
  909.  
  910. ------------------------------
  911.  
  912. From: -X-  How, in Tk, can I XXX:
  913. Subject: -Q9S- perform a non-blocking read on a file identifier?
  914.  
  915. A9S.  From Frank Smith <frank@arraysystems.nstn.ns.ca> we are told that
  916. if you have Extended Tcl, you can
  917.  
  918.    read $fileId [fstat $fileId size]
  919.  
  920. This will read only the number of bytes currently available on 'fileId'
  921. and consequently will not block.
  922.  
  923. ------------------------------
  924.  
  925. From: -X-  How, in Tk, can I XXX:
  926. Subject: -Q9T- read and write from a pipe without locking up?
  927.  
  928. A9T. The stdio package has an optimization for speed that buffers characters so 
  929. that you can avoid un-necessary system calls. This isn't very good for 
  930. interactive use so stdio changes it's behaviour if the file is a terminal. When 
  931. you write to a pipe you are not writing to a terminal and so your output is 
  932. buffered, similarly when the program at the other end of the pipe writes its 
  933. response it is also buffered. The end result is the programs at both end of the 
  934. pipe stall waiting for input. It is possible to force the buffers to be written 
  935. using flush in Tcl and fflush() in C, often though, you don't have control over 
  936. the program at the other end of the pipeline and in that case your only 
  937. solution is to use a pseudo-teletype (pty). Unfortunately this isn't all that 
  938. easy.
  939.  
  940. While this isn't directly supported in Tcl the spawn command in expect opens a 
  941. pty and starts a command.
  942.  
  943.  
  944. ------------------------------
  945.  
  946. From: -X-  How, in Tk, can I XXX:
  947. Subject: -Q10.A.1- get my wish application to execute - I just get a
  948.         wish prompt!  Or I just get error msgs about permission
  949.         denied, not found, etc.
  950.  
  951. A10.A.1. Most systems require a full pathname to the interpreter.  
  952. So you cannot start a wish script out as 
  953.  
  954. #! wish -f
  955.  
  956. Likewise, many Unix systems have a maximum length of characters that you can
  957. put on a #! line.  If you exceed this, you do not get the behaviour you
  958. expect.  So do not try to put something like:
  959.  
  960. #! /projects/somethingbig/bin/sun4/wish -f
  961.  
  962. followed by your wish code.  Keep the lines short - under 32 characters is
  963. recommended.
  964.  
  965. Finally, on some machines, white space after the -f causes a problem.  Be
  966. sure that the -f are the last characters on the first line of the file.
  967.  
  968. ------------------------------
  969.  
  970. From: -X-  How, in Tk, can I XXX:
  971. Subject: -Q10.A.2- ,using a machine with less than 8 bit color, run?
  972.  
  973. A10.A.2. Tk doesn't behave very well with less than 8-bit color screens.  To
  974. try to use it, find all the places in the Tk/wish source where 
  975. DefaultDepthOfScreen is invoked to test the number of bit-planes.  Change all
  976. of these to pretend there is just 1 bit-plane, or call a procedure which
  977. monitors a Tcl variable so that it is configurable, and you should be okay.
  978.  
  979. Another alternative is to see if the server you are using has alternative
  980. visual / color models, such as static visual, etc.  One of the alternatives
  981. may allow Tk to work better.
  982.  
  983. Thanks to "Nathaniel Borenstein" <nsb@thumper.bellcore.com> for this info!
  984.  
  985. ------------------------------
  986.  
  987. From: -X-  How, in Tk, can I XXX:
  988. Subject: -Q10.A.3- set X11 resources for a wish application in an 
  989.         app-defaults file?
  990.  
  991. A10.A.3. Read the documentation for the option command.
  992. Then you should consider something like the following - assume the program
  993. name is xwf.
  994.  
  995. The following are two general purpose functions to put into a library:
  996.  
  997. # envVal envValName
  998. #   Looks up the envValName environment variable and returns its
  999. #   value, or {} if it does not exists
  1000. proc envVal {envValName} {
  1001.   global env
  1002.   if [info exists env($envValName)] {return $env($envValName)} {return {}}
  1003. }
  1004.  
  1005. # loadAppDefaults classNameList ?priority?
  1006. #   Searches for the app-default files corresponding to classNames in
  1007. #   the order specified by X Toolkit Intrinsics, and loads them with
  1008. #   the priority specified (default: startupFile).
  1009. proc loadAppDefaults {classNameList {priority startupFile}} {
  1010.   set filepath "[split [envVal XUSERFILESEARCHPATH] :] \
  1011.         [envVal XAPPLRESDIR] \
  1012.         [split [envVal XFILESEARCHPATH] :] \
  1013.         /usr/lib/X11"
  1014.   foreach i $classNameList {
  1015.     foreach j $filepath {
  1016.       if {[file exists $j/$i]} {
  1017.     option readfile $j/$i $priority; break
  1018.       }
  1019.     }
  1020.   }
  1021. }
  1022.  
  1023. # Now, here is what you would put into xwf:
  1024.  
  1025. option add Tk.BoldFont "*-lucida sans-Bold-R-Normal-*-100-*" widgetDefault
  1026. loadAppDefaults {xwf XWF} userDefault
  1027.  
  1028. This sets a program default, then load any defaults specified in the user's
  1029. default resources and finally any site or general app-defaults resource.  
  1030. Of course, you would want to add some xwf command line handling to allow 
  1031. the user to override things at execution time.
  1032.  
  1033. ------------------------------
  1034.  
  1035. From: -X-  How, in Tk, can I XXX:
  1036. Subject: -Q10.A.4- specify bitmap patterns on the command line instead of 
  1037.         just as a file name?
  1038.  
  1039. A10.A.4. You can not, at least as of June, 1992.
  1040.  
  1041. ------------------------------
  1042.  
  1043. From: -X-  How, in Tk, can I XXX:
  1044. Subject: -Q10.A.5- get a Motif user interface?
  1045.  
  1046. A10.A.5. Tk does not currently use the Xt toolkit, so a strict adherence
  1047. to Motif via the libXm.a routines is not possible.  However, the authors
  1048. of Tk prefer the Motif style of user interface, so you will find that Tk
  1049. makes quite an attempt to implement a Motif-like interface.
  1050.  
  1051. ------------------------------
  1052.  
  1053. From: -X-  How, in Tk, can I XXX:
  1054. Subject: -Q10.A.6- get an OpenLook user interface?
  1055.  
  1056. A10.A.6. Unfortunately, Tk does not currently use either XView or Xt based
  1057. widgets in its user interface, so an OpenLook compliant (or even
  1058. similar) interface is probably not easily achievable in the near future.
  1059.  
  1060. ------------------------------
  1061.  
  1062. From: -X-  How, in Tk, can I XXX:
  1063. Subject: -Q10.A.7- get Tk 3.3 to even start - I get security error messages.
  1064.  
  1065. A10.A.7.  Alternate forms of this question often mention that Tk 3.3 send
  1066. is broken, or ask how to use xauth.
  1067.  
  1068. Under Tk 3.3, the X11 xauth security mechanism is used.  While this
  1069. provides more security, it does require the user to do a bit more
  1070. setup.  The user needs to create an Xauthority file (typically
  1071. $HOME/.Xauthority) and then restart the X server with the
  1072. -auth argument, along with the name of the Xauthority file created.
  1073. Read the X11 documentation for your system for the details on how to
  1074. use xauth or comparable software to create the authority files needed.
  1075. An intro to xauth is available as
  1076. ftp://harbor.ecn.purdue.edu/pub/tcl/docs/Xauthority .
  1077.  
  1078. Also note that you can configure Tk to not depend on xauth by modifying
  1079. the tk3.3/Makefile.in to comment out the following:
  1080.  
  1081. # To turn off the security checks that disallow incoming sends when
  1082. # the X server appears to be insecure, reverse the comments on the
  1083. # following lines:
  1084. #SECURITY_FLAGS =
  1085. SECURITY_FLAGS = -DTK_NO_SECURITY
  1086.  
  1087. ------------------------------
  1088.  
  1089. From: -X-  How, in Tk, can I XXX:
  1090. Subject: -Q10.B.1- change the default class bindings?
  1091.  
  1092. A10.B.1. All default class bindings for Tk widgets are initialized in
  1093. $tk_library/tk.tcl.  Use this file as a guide to implement new
  1094. bindings.  For instance, the following code duplicates Button 1's
  1095. drag-select facility in Button 3 for all listboxes:
  1096.  
  1097. bind Listbox <3> {%W select from [%W nearest %y]}
  1098. bind Listbox <B3-Motion> {%W select to [%W nearest %y]}
  1099.  
  1100. ------------------------------
  1101.  
  1102. From: -X-  How, in Tk, can I XXX:
  1103. Subject: -Q10.B.2- delete a binding?
  1104.  
  1105. A10.B.2. Give an empty-string command to the "bind" invocation.  For
  1106. example, to disable the Delete key in all entry fields:
  1107.  
  1108.     bind Entry <Delete> {}
  1109.  
  1110. ------------------------------
  1111.  
  1112. From: -X-  How, in Tk, can I XXX:
  1113. Subject: -Q10.B.3- change a binding while it is being executed?
  1114.  
  1115. A10.B.3. As of June, 1992, this was not a safe thing to do in Tk.  It was
  1116. put on the bug list by John Ousterhout to be fixed in a future version.
  1117.  
  1118. The solution for now is not to change the bindings, but to change
  1119. something in the code they execute.  For example, keep a state variable
  1120. that indicates which binding you'd like, but always have the binding
  1121. call a given procedure.  Then that procedure checks the variable and
  1122. executes one piece of code or another.  Or, you could just make the
  1123. binding's command "eval $cmd" and then change the variable "cmd"
  1124. depending on your application's state.
  1125.  
  1126. ------------------------------
  1127.  
  1128. From: -X-  How, in Tk, can I XXX:
  1129. Subject: -Q10.B.4- bind the arrow key on my Sun keyboard?
  1130.  
  1131. A10.B.4. You have to call it <Left> rather than <R10>.  Under X11, keys are
  1132. referred to by their keysym.  One can use either xmodmap -pk or the xev
  1133. program to determine what the keysym a particular key on a keyboard is
  1134. currently generating.
  1135.  
  1136. If the keysym that is being used is not known by Tk, you may have to edit
  1137. its ks_names.h file.  There is a note in this file that indicates that
  1138. one should not edit it - but this is where the keysym must be for it to
  1139. be recognized.
  1140.  
  1141. Thanks to Wayne Christopher <faustus@CS.Berkeley.EDU> for this
  1142. note.
  1143.  
  1144. ------------------------------
  1145.  
  1146. From: -X-  How, in Tk, can I XXX:
  1147. Subject: -Q10.B.5- get root's mouse bindings to work in my Tk application?
  1148.  
  1149. A10.B.5. Some window managers, such as mwm, define mouse button bindings
  1150. which cause Tk some problems.  Try saving off the window manager's startup
  1151. file (something like /.mwmrc for instance) and then copy in a startup
  1152. file from a login id that works.  Thanks to brad@NeoSoft.com (Brad Morrison)
  1153. for this invaluable tip!
  1154.  
  1155. ------------------------------
  1156.  
  1157. From: -X-  How, in Tk, can I XXX:
  1158. Subject: -Q10.C.1- get an application to also use libXt?
  1159.  
  1160. A10.C.1. Tk2.1 and Xt have different X connections, and XtAppNextEvent will
  1161. block is there is nothing coming from the X connection.  One way
  1162. of fixing this is get the connection number of Tk using
  1163.  
  1164.    ConnectionNumber(Tk_Display(tk_window));
  1165.  
  1166. and using XtAddInput to register this with the Xt event handler.  The
  1167. callback procedure for XtAddInput wrapper procedure that runs
  1168. Tk_OneEvent(1).  There might be problems with Tk file sources which
  1169. aren't registered with Xt.
  1170.  
  1171. Thanks to joe@astro.as.utexas.edu (Joe Wang) for this information.
  1172.  
  1173. ------------------------------
  1174.  
  1175. From: -X-  How, in Tk, can I XXX:
  1176. Subject: -Q10.C.2- change the X11 cursor?
  1177.  
  1178. A10.C.2. Here is a tip from mgc@cray.com (M. G. Christenson).
  1179.  
  1180. Look at /usr/include/X11/cursorfont.h for a list of available cursors.
  1181. You can use the names in there by removing the 'XC_'.  
  1182.  
  1183. Here's a little proc I use to make my entire application go 'busy'
  1184. while it's doing something. Just call it with the commands you want to
  1185. execute, and the watch cursor will be displayed for the time it takes
  1186. the commands to complete.  Note that any new windows will have their
  1187. normal cursor.
  1188.  
  1189. proc busy {cmds} {
  1190.     global errorInfo
  1191.  
  1192.     set busy {.app .root}
  1193.     set list [winfo children .]
  1194.     while {$list != ""} {
  1195.     set next {}
  1196.     foreach w $list {
  1197.         set class [winfo class $w]
  1198.         set cursor [lindex [$w config -cursor] 4]
  1199.         if {[winfo toplevel $w] == $w || $cursor != ""} {
  1200.         lappend busy [list $w $cursor]
  1201.         }
  1202.         set next [concat $next [winfo children $w]]
  1203.     }
  1204.     set list $next
  1205.     }
  1206.  
  1207.     foreach w $busy {
  1208.     catch {[lindex $w 0] config -cursor watch}
  1209.     }
  1210.  
  1211.     update idletasks
  1212.  
  1213.     set error [catch {uplevel eval [list $cmds]} result]
  1214.     set ei $errorInfo
  1215.  
  1216.     foreach w $busy {
  1217.     catch {[lindex $w 0] config -cursor [lindex $w 1]}
  1218.     }
  1219.  
  1220.     if $error {
  1221.     error $result $ei
  1222.     } else {
  1223.     return $result
  1224.     }
  1225. }
  1226.  
  1227. ------------------------------
  1228.  
  1229. From: -X-  How, in Tk, can I XXX:
  1230. Subject: -Q10.C.3- raise or lower a window?
  1231.  
  1232. A10.C.3. This is on the (semi-infinite) list of things to be done in the future.
  1233. If you have the time, please go ahead and add it and submit the code and all
  1234. will be grateful.
  1235.  
  1236. ------------------------------
  1237.  
  1238. From: -X-  How, in Tk, can I XXX:
  1239. Subject: -Q10.C.4- re-map a withdrawn window id?
  1240.  
  1241. A10.C.4. Use wm deiconify <windowid>.
  1242.  
  1243. ------------------------------
  1244.  
  1245. From: -X-  How, in Tk, can I XXX:
  1246. Subject: -Q10.C.5- use Tk in a subwindow of a non-Tk X11 application?
  1247.  
  1248. A10.C.5. From faustus@CS.Berkeley.EDU (Wayne A. Christopher):
  1249.  
  1250. [C]reate the Tk toplevel window but don't map it (wm withdraw).  Then
  1251. re-parent the window to be a subwindow of your other one and then map
  1252. it.  I have done this when the Tk application is a separate process,
  1253. but if it's the same process I think you will get into trouble with the
  1254. event loop, since each toolkit wants control.
  1255.  
  1256. ------------------------------
  1257.  
  1258. From: -X-  How, in Tk, can I XXX:
  1259. Subject: -Q10.C.6- bind <Enter> and <Leave> to a frame containing 
  1260.     other widgets?
  1261.  
  1262. A10.C.6. From John Ousterhout, ouster@cs.Berkeley.EDU):
  1263.  
  1264. Each <Enter> or <Leave> event has a "detail" field, which you can access
  1265. from bindings with "%d".  If the detail is "NotifyInferior" it means the
  1266. pointer has moved into or out of a child window (so it's really still in
  1267. the area of the window receiving the event).  You should be able to check
  1268. the detail in your scripts and ignore events with a detail of NotifyInferior.
  1269. Check the Xlib documentation for Enter/Leave events for complete
  1270. information on the detail field.
  1271.  
  1272.  
  1273. ------------------------------
  1274.  
  1275. From: -X-  How, in Tk, can I XXX:
  1276. Subject: -Q10.C.7- mix interactions between Xt and Tk/Tcl?
  1277.  
  1278. A10.C.7.
  1279.  
  1280. [From YIP Chi Lap [Beta] <h9118101@hkuxa.hku.hk> ]
  1281.     I have come up with a CPU hogging polling loop that
  1282. works (till now) for my application which not much
  1283. direct interaction between a Tk window and an Xt window is made.
  1284. (e.g., it won't draw something on a Tk window by a Xt-dispatched routine)
  1285.  
  1286.   XEvent xevent;
  1287.   for (;;)
  1288.   {
  1289.     if (XtAppPending(appcontext))
  1290.     {
  1291.       XtAppNextEvent(appcontext,&xevent);
  1292.       XtDispatchEvent(&xevent);
  1293.     }
  1294.     Tk_DoOneEvent(TK_DONT_WAIT);
  1295.   }
  1296.  
  1297. [ From David C Mudie <mudie@radon.eecs.berkeley.edu> ]
  1298.     We use the main event loop below.  The basic idea
  1299. is to watch for events arriving from either the Xt server
  1300. connection or the Tk server connection and then call
  1301. the library dispatchers.
  1302.  
  1303.     The code fragment below will need to be cleaned up for
  1304. your usage; there are some missing include statements
  1305. and global declarations buried elsewhere in the file.
  1306.  
  1307. /* Allow Tcl/Tk and Xt to work at the same time. */
  1308. void tkGo(void)
  1309. {
  1310.   extern Widget topLevel;
  1311.   int width = ulimit(4, -1);
  1312.   fd_set readfds;
  1313.   struct timeval timeout;
  1314.   int nfds;
  1315.   int tkfd = ConnectionNumber(Tk_Display(mainWindow));
  1316.   int xtfd = ConnectionNumber(XtDisplay(topLevel));
  1317.  
  1318.   Tcl_VarEval(interp, "update", NULL);
  1319.   while (1) {
  1320.  
  1321.     /* Select on X server connections to wait for event. */
  1322.     /* Timeout every half second to allow processing of non-X events */
  1323.  
  1324.     FD_ZERO(&readfds);
  1325.     FD_SET(tkfd, &readfds);
  1326.     FD_SET(xtfd, &readfds);
  1327.     timeout.tv_sec = 0;
  1328.     timeout.tv_usec = 500000;
  1329.  
  1330.     nfds = select(width, &readfds, NULL, NULL, &timeout);
  1331.     if (nfds < 0 && errno != EINTR) {
  1332.       perror("select");
  1333.     } else if (nfds == 0) {
  1334.       /* printf("timeout\n"); */
  1335.     }
  1336.  
  1337.     while (XtPending()) {
  1338.       XtProcessEvent(XtIMAll);
  1339.     }
  1340.  
  1341.     while (Tk_DoOneEvent(1)) {
  1342.       /* do nothing */
  1343.     }
  1344.   
  1345.     if (mainWindow == NULL) {
  1346. //      Tcl_DeleteInterp(interp);
  1347. //      Tcl_DStringFree(&command);
  1348.       Tcl_Eval(interp, "exit");
  1349.       return;
  1350.     }
  1351.   }
  1352. }
  1353.  
  1354. [ From Davide Frisoni <frisoni@faw.uni-ulm.de> ]
  1355.     One may use Xt properties to communicate between different
  1356. applications.
  1357.  
  1358.  
  1359. ------------------------------
  1360.  
  1361. From: -X-  How, in Tk, can I XXX:
  1362. Subject: -Q10.D.1- resize a listbox?
  1363.  
  1364. A10.D.1. Use wm min/maxsize - in a uniform manner.  Here is a resizable listbox:
  1365.  
  1366.         #!/usr/local/bin/wish -f
  1367.         wm minsize . 20 20
  1368.         wm maxsize . 1152 900
  1369.         pack append . [listbox .l -borderwidth 2 -relief raised] {expand fill}
  1370.  
  1371. Doing the same with the text widget brings its resizing under control too.
  1372.  
  1373. Thanks to "John C Ellson" <ellson@ontap.att.com).
  1374.  
  1375. ------------------------------
  1376.  
  1377. From: -X-  How, in Tk, can I XXX:
  1378. Subject: -Q10.D.2- select two items that are not adjacent in the listbox at 
  1379.         one time?
  1380.  
  1381. A10.D.2.  See Marc R. Ewing's Listbox.patch for a way to modify Tk to allow
  1382. selection of non-contiguous entries.
  1383.  
  1384. ------------------------------
  1385.  
  1386. From: -X-  How, in Tk, can I XXX:
  1387. Subject: -Q10.D.3- select items in more than one Tk listbox at a time?
  1388.  
  1389. A10.D.3. The default for Tk's listbox widget exports its selection as the
  1390. X selection.  There can only be one of these at a time.
  1391.  
  1392. To turn off this behavior in Tk, use the -exportselection false when
  1393. you create the listbox.  Or, use the
  1394.  
  1395. option add *Listbox.exportselection false
  1396.  
  1397. command in the beginning of your script.
  1398.  
  1399. Thanks to David Herron <david@davids.mmdf.com> for this tip.
  1400.  
  1401. ------------------------------
  1402.  
  1403. From: -X-  How, in Tk, can I XXX:
  1404. Subject: -Q10.D.4- avoid fractional white space at the end of a resizable
  1405.         listbox?
  1406.  
  1407. A10.D.4. First, let's state the problem more clearly. I want to make a
  1408. resizable listbox and I don't want to constrain it by setting a
  1409. minimum size. So I pack it with fill expand, I use it to set the grid
  1410. (so that resizing the window always gives me whole lines) and I set an
  1411. initial geometry of 1x1 to override the default. However what I get
  1412. is... (run the code below for a demo and try to resize)
  1413.  
  1414. listbox .l -geom 1x1 -setgrid 1 -yscrollcommand ".s set" -relief sunken -bd 2
  1415. scrollbar .s -command ".l yview"
  1416. pack .s -side right -fill y
  1417. pack .l -side top -fill both -expand 1
  1418. .l insert end one two three four five six seven eight nine ten "THE END"
  1419.  
  1420. ...a situation where the partially filled listbox has a blank
  1421. half-line at the bottom even if there are more items in the list. This
  1422. is very confusing because it fools the user into thinking that there
  1423. is nothing else beyond what's visible. Why does it happen?
  1424.  
  1425. Now for the answer.
  1426.     Look at the window as it is created, before the resizing. See that
  1427. poor, tiny little scrollbar squeezed in that microscopic window? It,
  1428. too, requests a minimum size, and it so happens that the starting
  1429. geometry for the listbox (i.e. the situation referred to as "1x1")
  1430. receives some free fractional space at the bottom. And you never get
  1431. rid of it, since the resizing is constrained to be in whole
  1432. characters.
  1433.  
  1434. The thing to do is to define the initial layout in such a way that the
  1435. widget that has -setgrid actually displays an integer number of lines
  1436. and columns. In the above example, setting -geom 1x2 does the trick.
  1437.  
  1438. Thanks to Frank Stajano <fms@cam-orl.co.uk> for this tip.
  1439.  
  1440. ------------------------------
  1441.  
  1442. From: -X-  How, in Tk, can I XXX:
  1443. Subject: -Q10.E.1- get output from a Tk canvas?
  1444.  
  1445. A10.E.1. The latest Tk has a save suboption on canvas which allows one
  1446. to create a file describing the canvas.  The default output is Encapsulated
  1447. Postscript, but there is an xpm3 suboption as well.
  1448.  
  1449. ------------------------------
  1450.  
  1451. From: -X-  How, in Tk, can I XXX:
  1452. Subject: -Q10.E.2- fill a canvas which is bounded by lines as opposed to a
  1453.         shape like a polygon, oval, etc.?
  1454.  
  1455. A10.E.2. No, you have to at least use a polygon if you want to fill an area
  1456. bounded by some lines.
  1457.  
  1458. ------------------------------
  1459.  
  1460. From: -X-  How, in Tk, can I XXX:
  1461. Subject: -Q10.E.3- raise/lower canvas window objects or draw graphics onto a 
  1462.         window object inside a canvas?
  1463.  
  1464. A10.E.3. You can't yet. 
  1465.  
  1466. "Jesper Blommaskog" <d9jesper@dtek.chalmers.se>.
  1467.  
  1468. ------------------------------
  1469.  
  1470. From: -X-  How, in Tk, can I XXX:
  1471. Subject: -Q10.E.4- detect when the canvas has been resized?
  1472.  
  1473. A10.E.4. From Nathaniel Pryce <np@hpl.hp.co.uk>:
  1474.  
  1475. > I have a window with a canvas containing some stuff that logically
  1476. > fills the canvas (say, a chess board or a map of the world). I want
  1477. > this toplevel window to be resizable and of course, when the win is
  1478. > resized, I want the stuff inside the canvas to be scaled
  1479. > accordingly. Now, I can manage the scaling of the stuff, but what
  1480. > I'm having trouble with is DETECTING that I should do it. How can I
  1481. > be notified that the window has been resized?
  1482.  
  1483. Nat's answer is:
  1484.  
  1485. You need to bind a command to the Configure event, like this:
  1486.  
  1487.     proc config {w h} {
  1488.        puts stdout ".canvas - width = $w, height = $h"
  1489.     }
  1490.  
  1491.     bind .canvas <Configure> "config %w %h"
  1492.  
  1493.  
  1494. .canvas - width = 224, height = 251
  1495. .canvas - width = 224, height = 151
  1496. .canvas - width = 224, height = 243
  1497. # and so forth
  1498.  
  1499. ------------------------------
  1500.  
  1501. From: -X-  How, in Tk, can I XXX:
  1502. Subject: -Q10.F.1- get the name of my own interpreter?
  1503.  
  1504. A10.F.1. george.howlett@att.com (George A. Howlett) points us to the winfo manual
  1505. page - winfo name . gets the name of the current application.
  1506.  
  1507. ------------------------------
  1508.  
  1509. From: -X-  How, in Tk, can I XXX:
  1510. Subject: -Q10.F.2- get -relief to work on my text widgets?
  1511.  
  1512. A10.F.2. From Owen Rees <rtor@ansa.co.uk>, we find out that we must:
  1513.  
  1514. "[m]ake the border width non-zero as in"
  1515.  
  1516.    text .t -width 20 -height 20 -relief sunken -borderwidth 4
  1517.  
  1518. ------------------------------
  1519.  
  1520. From: -X-  How, in Tk, can I XXX:
  1521. Subject: -Q10.F.3- create a scrollable window of buttons?
  1522.  
  1523. A10.F.3. There are at least two ways to do this.  First, there is a hypertext
  1524. widget that one can get from the Tcl User Contributed Code Archive -
  1525. (see "tcl-faq/part4") and (see "tcl-faq/part5") for details -
  1526.  which provides such a facility.
  1527.  
  1528. And here is some sample code from 
  1529. "Michael Moore" <mdm@stegosaur.cis.ohio-state.edu> which shows a way to 
  1530. do this using just Tk.
  1531.  
  1532. #! /bin/wish -f
  1533. #
  1534. # This demonstrates how to create a scrollable canvas with multiple
  1535. # buttons.
  1536. #
  1537. # Author : Michael Moore
  1538. # Date   : November 17, 1992
  1539. #
  1540.  
  1541. #
  1542. # This procedure obtains all the items with the tag "active"
  1543. # and prints out their ids.
  1544.  
  1545. proc multi_action {} {
  1546.     set list [.frame.canvas find withtag "active"]
  1547.     puts stdout "Active Item Ids : "
  1548.     foreach item $list {
  1549.     puts stdout $item
  1550.     }
  1551. }
  1552.  
  1553. # This simulates the toggling of a command button...
  1554. # Note that it only works on a color display as is right now
  1555. # but the principle is the same for b&w screens.
  1556. proc multi_activate {num id} {
  1557.     
  1558.     set tags [.frame.canvas gettags $id]
  1559.     if {[lsearch $tags "active"] != -1} {
  1560.     .frame.canvas dtag $id "active"
  1561.     .frame.canvas.button$num configure \
  1562.         -background "#060" \
  1563.         -activebackground "#080" 
  1564.     } else {
  1565.     .frame.canvas addtag "active" withtag $id
  1566.     .frame.canvas.button$num configure \
  1567.         -background "#600" \
  1568.         -activebackground "#800"
  1569.     }
  1570.  
  1571. proc setup {} {
  1572.      frame .frame
  1573.  
  1574.      scrollbar .frame.scroll \
  1575.          -command ".frame.canvas yview" \
  1576.          -relief raised
  1577.  
  1578.      canvas .frame.canvas \
  1579.          -yscroll ".frame.scroll set" \
  1580.          -scrollregion {0 0 0 650} \
  1581.          -relief raised \
  1582.      -confine false \
  1583.      -scrollincrement 25
  1584.  
  1585.      pack append .frame \
  1586.          .frame.scroll    {left frame center filly} \
  1587.          .frame.canvas    {left frame center fillx filly}
  1588.  
  1589.      pack append .\
  1590.          .frame   {left frame center fillx filly}
  1591.  
  1592.      button .frame.canvas.action  \
  1593.          -relief raised \
  1594.          -text "Action" \
  1595.      -command "multi_action"
  1596.      .frame.canvas create window 1 25 \
  1597.      -anchor w \
  1598.          -window .frame.canvas.action
  1599.      for {set i 2} {$i < 26} {incr i} {
  1600.      button .frame.canvas.button$i  \
  1601.         -relief raised \
  1602.         -background "#060" \
  1603.         -foreground wheat \
  1604.         -activebackground "#080" \
  1605.         -activeforeground wheat \
  1606.         -text "Button $i" 
  1607.      set id [.frame.canvas create window 1 [expr $i*25] \
  1608.         -anchor w \
  1609.         -window .frame.canvas.button$i]
  1610.      .frame.canvas.button$i configure \
  1611.         -command "multi_activate $i $id"
  1612.     }
  1613. }
  1614.  
  1615. setup
  1616.  
  1617. ------------------------------
  1618.  
  1619. From: -X-  How, in Tk, can I XXX:
  1620. Subject: -Q10.F.4- pack a text widget so that it can be resized interactively?
  1621.  
  1622. A10.F.4. From Spencer W. Thomas <spencer@med.umich.edu> we find that we need to:
  1623.  
  1624. wm minsize . 0 0
  1625. text .text
  1626. pack append . .text {fill expand}
  1627.  
  1628. ------------------------------
  1629.  
  1630. From: -X-  How, in Tk, can I XXX:
  1631. Subject: -Q10.F.5- create a widget with an upper case name?
  1632.  
  1633. A10.F.5. During a recent revision of Tk, things were changed so that names
  1634. beginning with a capital letter are reserved for class names.  Specific
  1635. instances of widgets must begin with a lower case letter.  This enables
  1636. X11 resource definitions to distinguish between a class and instance.
  1637.  
  1638. ------------------------------
  1639.  
  1640. From: -X-  How, in Tk, can I XXX:
  1641. Subject: -Q10.F.6- create equal sized buttons?
  1642.  
  1643. A10.F.6. Recently, Micael Salmon <etxmesa@eos.ericsson.se> posted:
  1644.  
  1645. In article <1993Jun23.065417.4302@ericsson.se>, I write:
  1646. |> I am currently working on yet another tn3270 emulator and I have run
  1647. |> into a problem with creating equal sized buttons. I have created an
  1648. |> array of buttons for PF and cursor keys and I would now like to make
  1649. |> them all the same size. Arranging them into columns was not
  1650. |> a problem but when I add bitmaps the buttons lose their horizontal
  1651. |> alignment. What I tried was to read the height and width of the buttons
  1652. |> using winfo, determine the largest and then use pads to force them to
  1653. |> be the same size, this doesn't seem to work. The technique of using
  1654. |> pre-set height and width doesn't seem applicable when using a mixture
  1655. |> of bitmaps and text as the size in pixels of a text button is font
  1656. |> dependent. All suggestions welcome.
  1657.  
  1658. Jim Wight <J.K.Wight@newcastle.ac.uk> suggested using reqheight and reqwidth
  1659. and then specifying padx and pady in the pack command for each button.
  1660. Jim says:
  1661. I think it only fair to point out that it was Tuomas J Lukka
  1662. <lukka@klaava.Helsinki.FI> who suggested the use of reqwidth and reqheight when I asked how to get over the deficiencies in my first attempt at a solution
  1663. that I posted to this group.
  1664.  
  1665. Since you're all agog I might as well post the final solution (more or less)
  1666. that I mailed to Michael.
  1667.  
  1668. frame .frame1
  1669. frame .frame2
  1670. button .frame1.a -text "pretty long button text"
  1671. button .frame1.b -text "short one"
  1672. button .frame2.c -bitmap "@/usr/include/X11/bitmaps/xlogo32"
  1673. button .frame2.d -text "tiny"
  1674.  
  1675. set long [winfo reqwidth .frame1.a]
  1676. set short [winfo reqwidth .frame1.b]
  1677. set medium [winfo reqwidth .frame2.c]
  1678. set tiny [winfo reqwidth .frame2.d]
  1679. set pady [expr [winfo reqheight .frame2.c]-[winfo reqheight .frame2.d]]
  1680.  
  1681. pack append .frame1 .frame1.a "filly pady $pady"
  1682. pack append .frame1 .frame1.b "fillx padx [expr $long-$short] filly pady $pady"pack append .frame2 .frame2.c "fillx padx [expr $long-$medium] filly"
  1683. pack append .frame2 .frame2.d "fillx padx [expr $long-$tiny] filly pady $pady"
  1684. pack append . .frame1 {left} .frame2 {left}
  1685.  
  1686.  
  1687. ------------------------------
  1688.  
  1689. From: -X-  How, in Tk, can I XXX:
  1690. Subject: -Q10.F.7- vertically stack radio buttons aligning regardless of font?
  1691.  
  1692. A10.F.7.  Till Brychcy <brychcy@informatik.tu-muenchen.de> provides
  1693. the following example:
  1694.  
  1695.  
  1696.     radiobutton .times -text Times -anchor w
  1697.     radiobutton .helvetica -text Helvetica -anchor w
  1698.     radiobutton .courier -text Courier -anchor w
  1699.     pack .times .helvetica .courier -side top -fill x
  1700.  
  1701. Note that you are using anchor west in the widgets themselves, and not in
  1702. the packer.  This lets the packer produce full width buttons.
  1703.  
  1704.  
  1705. ------------------------------
  1706.  
  1707. From: -X-  How, in Tk, can I XXX:
  1708. Subject: -Q10.F.8- initialize an entry widget with some text?
  1709.  
  1710. A10.F.8.  kesch@kappco.kapp-coburg.de (Peter Kesch) provides us with
  1711. one example:
  1712.  
  1713. set default "foobar"
  1714. entry .foo -width 25 -state disabled -textvariable default
  1715.  
  1716.  
  1717. ------------------------------
  1718.  
  1719.  
  1720. End of comp.lang.tcl Frequently Asked Questions (2/5)
  1721. *****************************************************
  1722. -- 
  1723. :s Great net resources sought...
  1724. :s Larry W. Virden                 INET: lvirden@cas.org
  1725. :s Personal: 674 Falls Place,   Reynoldsburg, OH 43068-1614
  1726. The task of an educator should be to irrigate the desert not clear the forest.
  1727. -- 
  1728. :s Great net resources sought...
  1729. :s Larry W. Virden                 INET: lvirden@cas.org
  1730. :s Personal: 674 Falls Place,   Reynoldsburg, OH 43068-1614
  1731. The task of an educator should be to irrigate the desert not clear the forest.
  1732.